<%-- 
    Document   : index
    Created on : 25.2.2011, 12:16:20
    Author     : Martin Řehánek (rehan at mzk.cz)
--%>

<%@page import="cz.mzk.kramerius.commons.PropertyLoader"%>
<%@page import="cz.mzk.oai.provider.Configuration"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="cz.mzk.oai.metadataRepository.metadata.MetadataFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>OaiMzk</title>
        <style type="text/css" media="Screen">
            table {
                width: auto;
                height: 1px;
                table-layout: auto;
                border-collapse: collapse;
                margin: 20px;
            }

            caption{
                padding: .2em .8em;
                border: 1px solid #fff;
                background: #e6d88c;
                /*font-weight: bold;*/
                font-size: 1.1em;
            }

            th{
                width: 50px;
                height: 1px;
                overflow: hidden;
                visibility: visible;
                border: 1px solid black;
                padding: 5px;
                background: #2a65e2;
                text-align: right;
                vertical-align: middle;
                text-indent: 5px;
            }

            td {
                width: 50px;
                height: 1px;
                overflow: hidden;
                visibility: visible;
                /*  border: 1px solid black;*/
                padding: 5px;
                background: #21bdc6;
                text-align: right;
                vertical-align: middle;
                text-indent: 5px;
            }

            .logo{
            }

            .mzk {
                color: #21bdc6;
                font-style: italic;
                margin:0px;
                border: 0px;
                padding:0px;

            }
            .oai {
                font-style: italic;
                color: #23669f;
                margin:0px;
                border: 0px;
                padding:0px;
            }
        </style>
    </head>
    <body>
        <%
            PropertyLoader loader = Configuration.getPropertyLoader();
            String adminEmail = loader.loadString("provider.adminEmail");
            String adminName = loader.loadString("provider.adminName");
        %>

        <h1 align="center">
            <span class=".logo">
                <span class="mzk">M</span><span class="oai">o</span><span class="mzk">Z</span><span class="oai">a</span><span class="mzk">K</span><span class="oai">i</span>
            </span>
            <!--<span>OAI-PMH data provider</span>-->
        </h1>
        <h2 align="center" style="color: grey">
            OAI-PMH data provider
        </h2>

        <p class="descriptionText">
            <h3>General information</h3>
            Welcome to <a href="http://www.openarchives.org/OAI/openarchivesprotocol.html">OAI-PMH</a>
            data provider implementation called
            <b>
                <span class=".logo">
                    <span class="mzk">M</span><span class="oai">o</span><span class="mzk">Z</span><span class="oai">a</span><span class="mzk">K</span><span class="oai">i</span>
                </span>
            </b>
            .
            This software is being developed under
            <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU GPL v2 license</a>
            by
            <a href="http://www.mzk.cz/">Moravian Library in Brno</a>
            and is primarily used for needs of this organization.
            All the source code is available at
            <a href="http://code.google.com/p/joai-mzk/">Google Code</a>.
        </p>
        <p>
            For more information and troubleshooting please contact administrator
            <a href="mailto:<%=adminEmail%>"><%=adminName%></a>.
        </p>
        <p>
            <h3>Web interface description</h3>
            Each row in table below represents single operation.
            Each column allways contains button with name of the operation,
            clicking on the button launches the operation.
            Rest of the columns contain those parameters, that are applicable to given operation.
            Some operations are available in more than one form and are therefore present in multiple rows.
            For example there are versions of <i>ListIdentifiers</i> and <i>ListRecords</i> for initial request
            and versions for following requests identified by
            <a href="http://www.openarchives.org/OAI/openarchivesprotocol.html#FlowControl"><i>resumtion tokens</i></a>.
        </p>


        <div>
            <table align="left" rules="all">
                <caption>OAI-PMH requests</caption>
                <tr>
                    <th>verb</th>
                    <th>metadataPrefix</th>
                    <th>identifier</th>
                    <th>from</th>
                    <th>until</th>
                    <th>set</th>
                    <th>resumptionToken</th>
                </tr>
                <tr>
                    <form>
                        <input type="hidden" name="verb" value="Identify"/>
                        <td>
                            <input type="submit" value="Identify"/>
                        </td>
                    </form>
                    <td/><td/><td/><td/><td/><td/>
                </tr>
                <tr>

                    <form onsubmit="return disableEmptyInputs(this)">
                        <td><input type="submit" value="ListSets"/></td>
                        <input type="hidden" name="verb" value="ListSets"/>
                    </form>
                    <td/><td/><td/><td/><td/><td/>
                </tr>
                <tr>
                    <form>
                        <td><input type="submit" value="ListSets"/></td>
                        <input type="hidden" name="verb" value="ListSets"/>
                        <td/><td/><td/><td/><td/>
                        <td><input type="text" name="resumptionToken" size="10" /></td>
                    </form>
                </tr>
                <tr>
                    <form onsubmit="return disableEmptyInputs(this)">
                        <td><input type="submit" value="ListMetadataFormats"/></td>
                        <input type="hidden" name="verb" value="ListMetadataFormats"/>
                        <td/>
                        <td><input type="text"  size="10"name="identifier"/></td>
                    </form>
                    <td/><td/><td/><td/>
                </tr>
                <tr>
                    <form onsubmit="return disableEmptyInputs(this)">
                        <td><input type="submit" value="GetRecord"/></td>
                        <input type="hidden" name="verb" value="GetRecord"/>
                        <td>
                            <select name="metadataPrefix">
                                <% for (MetadataFormat format : MetadataFormat.values()) {%>
                                <option value="<%=format.toString()%>"><%=format.toString()%>
                                </option>
                                <%}
                                    ;%>
                            </select>
                        </td>
                        <td><input type="text"  size="10"name="identifier"/></td>
                    </form>
                    <td/><td/><td/><td/>
                </tr>
                <tr>
                </tr>
                <tr>
                    <form onsubmit="return disableEmptyInputs(this)">
                        <td><input type="submit" value="ListIdentifiers"/></td>
                        <input type="hidden" name="verb" value="ListIdentifiers"/>
                        <td>
                            <select name="metadataPrefix">
                                <% for (MetadataFormat format : MetadataFormat.values()) {%>
                                <option value="<%=format.toString()%>"><%=format.toString()%>
                                </option>
                                <%}
                                    ;%>
                            </select>
                        </td>
                        <td/>
                        <td><input type="text"  size="10"name="from"/></td>
                        <td><input type="text"  size="10"name="until"/></td>
                        <td><input type="text"  size="10"name="set"/></td>
                    </form>
                    <td/>
                </tr>
                <tr>
                    <form>
                        <td><input type="submit" value="ListIdentifiers"/></td>
                        <input type="hidden" name="verb" value="ListIdentifiers"/>
                        <td/><td/><td/><td/><td/>
                        <td><input type="text"  size="10"name="resumptionToken"/></td>
                    </form>
                </tr>
                <tr>
                    <form onsubmit="return disableEmptyInputs(this)">
                        <td><input type="submit" value="ListRecords"/></td>
                        <input type="hidden" name="verb" value="ListRecords"/>
                        <td>
                            <select name="metadataPrefix">
                                <% for (MetadataFormat format : MetadataFormat.values()) {%>
                                <option value="<%=format.toString()%>"><%=format.toString()%>
                                </option>
                                <%}
                                    ;%>
                            </select>
                        </td>
                        <td/>
                        <td><input type="text"  size="10"name="from"/></td>
                        <td><input type="text"  size="10"name="until"/></td>
                        <td><input type="text"  size="10"name="set"/></td>
                    </form>
                    <td/>
                </tr>
                <tr>
                    <form>
                        <td><input type="submit" value="ListRecords"/></td>
                        <input type="hidden" name="verb" value="ListRecords"/>
                        <td/><td/><td/><td/><td/>
                        <td><input type="text"  size="10"name="resumptionToken"/></td>
                    </form>
                </tr>
            </table>
        </div>
        <div>
            <table align="left" rules="all" >
                <caption>extension for identifiers based on Aleph <i>base</i> and <i>sysno</i></caption>
                <tr>
                    <th>verb</th>
                    <th>metadataFormat</th>
                    <th>id prefix</th>
                    <th>base</th>
                    <th>sysno</th>
                </tr>
                <tr>
                    <form onsubmit="return buildIdentifier(this)">
                        <td>
                            <input type="submit" value="GetRecord"/>
                        </td>
                        <input type="hidden" name="verb" value="GetRecord"/>
                        <input type="hidden" name="identifier"/>
                        <td>
                            <select name="metadataPrefix">
                                <% for (MetadataFormat format : MetadataFormat.values()) {%>
                                <option value="<%=format.toString()%>"><%=format.toString()%>
                                </option>
                                <%}
                                    ;%>
                            </select>
                        </td>
                        <td>
                            <input type="text"  size="15"name="idPrefix" value="oai:aleph.mzk.cz"/>
                        </td>
                        <td>
                            <select name="base">
                                <option value="MZK03">MZK03</option>
                                <option value="MZK01">MZK01</option>
                            </select>
                        </td>
                        <td>
                            <input type="text" size="10"name="sysno"/>
                        </td>
                    </form>
                </tr>
                <tr>
                    <form onsubmit="return buildIdentifier(this)">
                        <td>
                            <input type="submit" value="ListMetadataFormats"/>
                        </td>
                        <input type="hidden" name="verb" value="ListMetadataFormats"/>
                        <input type="hidden" name="identifier"/>
                        <td/>
                        <td>
                            <input type="text"  size="15"name="idPrefix" value="oai:aleph.mzk.cz"/>
                        </td>
                        <td>
                            <select name="base">
                                <option value="MZK03">MZK03</option>
                                <option value="MZK01">MZK01</option>
                            </select>
                        </td>
                        <td>
                            <input type="text" size="10"name="sysno"/>
                        </td>
                    </form>
                </tr>
            </table>
        </div>

        <script type="text/javascript" >
            function disableEmptyInputs(form){
                for (i=0;i<form.elements.length;i++){
                    element = form.elements[i];
                    //            console.log("index: " + i);
                    //            console.log("type: " + element.type);
                    //            console.log("name: " + element.name);
                    //            console.log("value: " + element.value);
                    if(isEmpty(element.value)){
                        element.disabled = true;
                    }
                }
                return true;
                //return false;
            }

            function isEmpty(value){
                return (value == "");
            }

            function buildIdentifier(form){
                prefix = form.elements["idPrefix"];
                base = form.elements["base"];
                sysno = form.elements["sysno"];
                identifier = prefix.value + ":" + base.value + "-" + sysno.value ;
                form.elements["identifier"].value = identifier;
                prefix.disabled = true;
                base.disabled = true;
                sysno.disabled = true;
                //console.log(identifier);
                //return false;
                return true;
            }    
        </script>
    </body>
</html>

